package oop.java0406;

public class Teacher {
    private String name;
    private String school;
    private int age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSchool() {
        return school;
    }

    public void setSchool(String school) {
        this.school = school;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) throws RuntimeException {
        if (age < 22) {
            throw new RuntimeException();
        }
        this.age = age;
    }

    @Override
    public String toString() {
        return "自我介绍：\n" + "我叫" + name + ", 在" + school + "工作，今年" + age + "岁了";
    }
    public void teach(){
        System.out.println("我使用扩音器上课");
    }
}
